package com.gxjc.dao.bean;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.gxjc.model.NodeData;
import com.gxjc.model.User;

public class NodeDataDao extends BaseDao {
	public List<NodeData> getAll() {
		String hql = "FROM NodeData";
		return getSession().createQuery(hql).list();
	}
	public void save(NodeData nodeData) {
		Session session = getSession();
		//session.merge(nodeData);
		session.save(nodeData);
		//session.getTransaction().commit();
		//session.close();
	}
	public void update(NodeData nodeData) {
		//Session session = getSession();
		getSession().update(nodeData);
		//session.getTransaction().commit();
		//session.close();
	}
	
	public void delete(int id) {
		getSession().delete(getSession().get(NodeData.class,id));
	}
	
	public NodeData getNodeDataById(int id) {
		return (NodeData)getSession().get(NodeData.class,id);
	}
	
	public List<NodeData> getNodeDataBySql(String hql) {
		return getSession().createQuery(hql).list();
	}
	public List<NodeData> getNodeDataBySql(String hql,int limit) {
		Query  query  = getSession().createQuery(hql);
		query.setFirstResult(0);
		query.setMaxResults(limit);
		return query.list();
	}
}
